package com.wavehi.producer;

import com.rabbitmq.client.Channel;
import com.wavehi.util.RabbitMQFactoryUtils;

import java.io.IOException;
import java.util.Scanner;

/**
 * @Description  生产者 演示重新入队
 * @Author WaveHi
 * @Date 24/12/2021 下午 4:47
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 */
public class Producer_02 {

    private static final String QUEUE_NAME = "ack_queue";

    public static void main(String[] args) throws Exception {

        //1.创建信道
        Channel channel = RabbitMQFactoryUtils.getChannel();
        //2.声明队列
        channel.queueDeclare(QUEUE_NAME, false, false, false,null);
        //3.准备消息
        Scanner scanner = new Scanner(System.in);
        String message = null;
        //4.发送消息
        while(scanner.hasNext()) {
            message = scanner.next();
            channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8"));
            System.out.println("Send message : " + message);
        }
    }
}
